package com.bitdf.txing.search.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.bitdf.txing.common.utils.R;
import com.bitdf.txing.search.service.MallProductSearchService;
import com.bitdf.txing.search.vo.SearchParam;
import com.bitdf.txing.search.vo.SearchResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("${txing.request.path.search}/mall/product")
public class MallProductSearchController {

    @Autowired
    MallProductSearchService mallSearchService;

    /**
     * 检索商品
     * @param param
     * @param request
     * @return
     */
    @SaCheckLogin
    @SaCheckPermission("mall:search:product:search")
    @PostMapping("/search")
    public R listpagea(@RequestBody SearchParam param, HttpServletRequest request)
    {
        String queryString = request.getQueryString();
        param.set_queryString(queryString);
        SearchResult result=mallSearchService.search(param);
        return R.ok(result);
    }
}
